package vo

import (
	"go-mall/app/client/model"
	"time"
)

type UserVO struct{}

type LoginRes struct {
	User      UserInfoRes `json:"user"`
	Token     string      `json:"token"`
	ExpiresAt any         `json:"expiresAt"`
}

func (v *UserVO) Login(user model.User, token string, expiresAt any) *LoginRes {
	return &LoginRes{
		User: UserInfoRes{
			UserName: user.UserName,
			NickName: user.NickName,
			RealName: user.RealName,
			ImgUrl:   user.ImgUrl,
			Email:    user.Email,
			Sex:      user.Sex,
			Birthday: user.Birthday,
			Sign:     user.Sign,
		},
		Token:     token,
		ExpiresAt: expiresAt,
	}
}

type UserInfoRes struct {
	ID       uint      `json:"id"`
	UserName string    `json:"username"`
	NickName string    `json:"nickname"`
	RealName string    `json:"realName"`
	ImgUrl   string    `json:"imgUrl"`
	Email    string    `json:"email"`
	mobile   string    `json:"mobile"`
	Sex      uint      `json:"sex"`
	Birthday time.Time `json:"birthday"`
	Sign     string    `json:"sign"`
}

func (v *UserVO) UserInfo(user model.User) *UserInfoRes {
	return &UserInfoRes{
		ID:       user.ID,
		UserName: user.UserName,
		NickName: user.NickName,
		RealName: user.RealName,
		ImgUrl:   user.ImgUrl,
		Email:    user.Email,
		Sex:      user.Sex,
		Birthday: user.Birthday,
		Sign:     user.Sign,
	}
}
